//
//  ViewController.m
//  JKRuntimeTextFiledTest
//
//  Created by 王冲 on 2018/10/10.
//  Copyright © 2018年 JK科技有限公司. All rights reserved.
//

#import "ViewController.h"
#import <objc/runtime.h>
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITextField *textFiled = [[UITextField alloc]initWithFrame:CGRectMake(50, 100, 200, 50)];
    textFiled.backgroundColor = [UIColor brownColor];
    
    // 第1种修改颜色
    //textFiled.attributedPlaceholder = [[NSMutableAttributedString alloc]initWithString:@" 请输入手机号" attributes:@{NSForegroundColorAttributeName:[UIColor redColor]}];
    
    
    // _placeholderLabel @"UITextFieldLabel"
    textFiled.placeholder = @"请输入手机号";
    
    // 第2种修改颜色
    //    UILabel *placeholderLabel = [textFiled valueForKeyPath:@"_placeholderLabel"];
    //    placeholderLabel.textColor = [UIColor greenColor];
    // 第3种修改颜色
    [textFiled setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
    
    
    id placeholderLabel = [textFiled valueForKeyPath:@"_placeholderLabel"];
    NSLog(@"%@ %@",[placeholderLabel class],[placeholderLabel superclass]);
    
    [self.view addSubview:textFiled];
    
    
    /*
     unsigned int count;
     Ivar *ivars = class_copyIvarList([UITextField class], &count);
     for (int i = 0; i < count; i++) {
     // 取出i位置的成员变量
     Ivar ivar = ivars[i];
     NSLog(@"%s %s", ivar_getName(ivar), ivar_getTypeEncoding(ivar));
     }
     free(ivars);
     */
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end

